package cn.gson.fengboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Zorder {
    private Integer orderId;//订单ID
    private TfyclientForm clientId;//客户
    private Zcontract conId;//合同
    private String orderNo;//编号
    private String orderTheme;//主题
    private BigDecimal orderTotal;//订单总金额
    private BigDecimal orderReturned;//订单剩余回款金额
    private BigDecimal orderInvoice;//订单开票金额
    private BigDecimal orderGross;//订单毛利
    private Timestamp orderTime;//订单下单日期
    private Timestamp orderWctime;//订单完成日期
    private String orderExchange;//订单是否换货
    private String orderReturn;//订单是否退货
    private String orderState;//订单状态
    private String orderRemark;//订单备注
    private String orderPeople;//订单负责员工
    private Integer orderZt;//是否删除状态
    private String orderJfzt;//是否交付状态
    private String orderHkzt;//是否回款状态
    private Collection<Zbarter> zbartersByOrderId;
    private List<Zorderdetails> zorderdetailsByOrderId;
    private Zbarter barterId;

    @Id
    @Column(name = "order_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    @ManyToOne
    @JoinColumn(name = "client_id")
    public TfyclientForm getClientId() {
        return clientId;
    }

    public void setClientId(TfyclientForm clientId) {
        this.clientId = clientId;
    }

    @ManyToOne
    @JoinColumn(name = "con_id")
    public Zcontract getConId() {
        return conId;
    }

    public void setConId(Zcontract conId) {
        this.conId = conId;
    }

    @Basic
    @Column(name = "order_jfzt")
    public String getOrderJfzt() {
        return orderJfzt;
    }

    public void setOrderJfzt(String orderJfzt) {
        this.orderJfzt = orderJfzt;
    }

    @Basic
    @Column(name = "order_hkzt")
    public String getOrderHkzt() {
        return orderHkzt;
    }

    public void setOrderHkzt(String orderHkzt) {
        this.orderHkzt = orderHkzt;
    }

    @Basic
    @Column(name = "order_wctime")
    public Timestamp getOrderWctime() {
        return orderWctime;
    }

    public void setOrderWctime(Timestamp orderWctime) {
        this.orderWctime = orderWctime;
    }


    @ManyToOne
    @JoinColumn(name = "barter_id")
    public Zbarter getBarterId() {
        return barterId;
    }

    public void setBarterId(Zbarter barterId) {
        this.barterId = barterId;
    }

    @Basic
    @Column(name = "order_no")
    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    @Basic
    @Column(name = "order_zt")
    public Integer getOrderZt() {
        return orderZt;
    }

    public void setOrderZt(Integer orderZt) {
        this.orderZt = orderZt;
    }

    @Basic
    @Column(name = "order_theme")
    public String getOrderTheme() {
        return orderTheme;
    }

    public void setOrderTheme(String orderTheme) {
        this.orderTheme = orderTheme;
    }

    @Basic
    @Column(name = "order_total")
    public BigDecimal getOrderTotal() {
        return orderTotal;
    }

    public void setOrderTotal(BigDecimal orderTotal) {
        this.orderTotal = orderTotal;
    }

    @Basic
    @Column(name = "order_returned")
    public BigDecimal getOrderReturned() {
        return orderReturned;
    }

    public void setOrderReturned(BigDecimal orderReturned) {
        this.orderReturned = orderReturned;
    }

    @Basic
    @Column(name = "order_invoice")
    public BigDecimal getOrderInvoice() {
        return orderInvoice;
    }

    public void setOrderInvoice(BigDecimal orderInvoice) {
        this.orderInvoice = orderInvoice;
    }

    @Basic
    @Column(name = "order_gross")
    public BigDecimal getOrderGross() {
        return orderGross;
    }

    public void setOrderGross(BigDecimal orderGross) {
        this.orderGross = orderGross;
    }

    @Basic
    @Column(name = "order_time")
    public Timestamp getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Timestamp orderTime) {
        this.orderTime = orderTime;
    }

    @Basic
    @Column(name = "order_exchange")
    public String getOrderExchange() {
        return orderExchange;
    }

    public void setOrderExchange(String orderExchange) {
        this.orderExchange = orderExchange;
    }

    @Basic
    @Column(name = "order_return")
    public String getOrderReturn() {
        return orderReturn;
    }

    public void setOrderReturn(String orderReturn) {
        this.orderReturn = orderReturn;
    }

    @Basic
    @Column(name = "order_state")
    public String getOrderState() {
        return orderState;
    }

    public void setOrderState(String orderState) {
        this.orderState = orderState;
    }

    @Basic
    @Column(name = "order_remark")
    public String getOrderRemark() {
        return orderRemark;
    }

    public void setOrderRemark(String orderRemark) {
        this.orderRemark = orderRemark;
    }

    @Basic
    @Column(name = "order_people")
    public String getOrderPeople() {
        return orderPeople;
    }

    public void setOrderPeople(String orderPeople) {
        this.orderPeople = orderPeople;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zorder zorder = (Zorder) o;
        return orderId == zorder.orderId &&
                Objects.equals(clientId, zorder.clientId) &&
                Objects.equals(conId, zorder.conId) &&
                Objects.equals(orderNo, zorder.orderNo) &&
                Objects.equals(orderTheme, zorder.orderTheme) &&
                Objects.equals(orderTotal, zorder.orderTotal) &&
                Objects.equals(orderReturned, zorder.orderReturned) &&
                Objects.equals(orderInvoice, zorder.orderInvoice) &&
                Objects.equals(orderGross, zorder.orderGross) &&
                Objects.equals(orderTime, zorder.orderTime) &&
                Objects.equals(orderExchange, zorder.orderExchange) &&
                Objects.equals(orderReturn, zorder.orderReturn) &&
                Objects.equals(orderState, zorder.orderState) &&
                Objects.equals(orderRemark, zorder.orderRemark) &&
                Objects.equals(orderPeople, zorder.orderPeople);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderId, clientId, conId, orderNo, orderTheme, orderTotal, orderReturned, orderInvoice, orderGross, orderTime, orderExchange, orderReturn, orderState, orderRemark, orderPeople);
    }

    @OneToMany(mappedBy = "orderId")
    public Collection<Zbarter> getZbartersByOrderId() {
        return zbartersByOrderId;
    }

    public void setZbartersByOrderId(Collection<Zbarter> zbartersByOrderId) {
        this.zbartersByOrderId = zbartersByOrderId;
    }

    @OneToMany(mappedBy = "orderId")
    public List<Zorderdetails> getZorderdetailsByOrderId() {
        return zorderdetailsByOrderId;
    }

    public void setZorderdetailsByOrderId(List<Zorderdetails> zorderdetailsByOrderId) {
        this.zorderdetailsByOrderId = zorderdetailsByOrderId;
    }

    @Override
    public String toString() {
        return "Zorder{" +
                "orderId=" + orderId +
                ", clientId=" + clientId +
                ", conId=" + conId +
                ", orderNo='" + orderNo + '\'' +
                ", orderTheme='" + orderTheme + '\'' +
                ", orderTotal=" + orderTotal +
                ", orderReturned=" + orderReturned +
                ", orderInvoice=" + orderInvoice +
                ", orderGross=" + orderGross +
                ", orderTime=" + orderTime +
                ", orderWctime=" + orderWctime +
                ", orderExchange='" + orderExchange + '\'' +
                ", orderReturn='" + orderReturn + '\'' +
                ", orderState='" + orderState + '\'' +
                ", orderRemark='" + orderRemark + '\'' +
                ", orderPeople='" + orderPeople + '\'' +
                ", orderZt=" + orderZt +
                ", zbartersByOrderId=" + zbartersByOrderId +
                ", zorderdetailsByOrderId=" + zorderdetailsByOrderId +
                '}';
    }
}
